package com.black.framework.config.handler;

import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * app用户退出自定义实现
 */
@Component
public class AppLogoutSuccessHandlerImpl implements LogoutSuccessHandler {


    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {

//        //获取令牌
//       AdminUserDetails  adminUserDetails = adminTokenService.getLoginUser(request);
//       if (adminUserDetails != null) {
//           //删除redis中的令牌
//           adminTokenService.delLoginUser(adminUserDetails.getToken());
//           // 记录用户退出日志
//           AsyncManager.me().execute(AsyncTimerTaskFactory.recordLogininfor(adminUserDetails.getUsername(),
//                   Constants.LOGOUT, MessageUtils.message("user.logout.success")));
//       }
//
//        R<Object> ok = R.ok(null, MessageUtils.message("user.logout.success"));
//        ServletUtils.renderString(response, JSONUtil.toJsonStr(ok));
    }
}
